package com.ewanghuiju.app.util;

import android.app.Activity;

import com.ewanghuiju.app.R;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;

/**
 * @author sj  qq:751943509
 * @class describe
 * @time 2020/3/31
 */
public class ShareUtils {
    /**
     * 文本加图片
     *
     * @param activity
     * @param share_media
     * @param text
     * @param shareListener
     */
    public void shareTextAndImage(Activity activity, SHARE_MEDIA share_media, String text, UMShareListener shareListener) {
        UMImage imagelocal = new UMImage(activity, R.mipmap.ic_launcher);
        imagelocal.setThumb(new UMImage(activity, R.mipmap.ic_launcher));
        new ShareAction(activity).withText(text)
                .withMedia(imagelocal)
                .setPlatform(share_media)
                .setCallback(shareListener).share();
    }

    /**
     * 多图分享
     *
     * @param activity
     * @param share_media
     * @param shareListener
     */
    public void shareMulImage(Activity activity, SHARE_MEDIA share_media, UMShareListener shareListener) {
        UMImage imagelocal1 = new UMImage(activity, R.mipmap.ic_launcher);
        imagelocal1.setThumb(new UMImage(activity, R.mipmap.ic_launcher));
        UMImage imagelocal2 = new UMImage(activity, R.mipmap.ic_launcher);
        imagelocal2.setThumb(new UMImage(activity, R.mipmap.ic_launcher));
        new ShareAction(activity).withText("多图分享").withMedias(imagelocal1, imagelocal2)
                .setPlatform(share_media)
                .setCallback(shareListener).share();
    }

    /**
     * 分享文本
     *
     * @param activity
     * @param share_media
     * @param text
     * @param shareListener
     */
    public static void shareText(Activity activity, SHARE_MEDIA share_media, String text, UMShareListener shareListener) {
        new ShareAction(activity).withText(text)
                .setPlatform(share_media)
                .setCallback(shareListener).share();
    }

    /**
     * 分享本地图片
     *
     * @param activity
     * @param share_media
     * @param shareListener
     */
    public void shareImageLocal(Activity activity, SHARE_MEDIA share_media, UMShareListener shareListener) {
        UMImage imagelocal = new UMImage(activity, R.mipmap.ic_launcher);
        imagelocal.setThumb(new UMImage(activity, R.mipmap.ic_launcher));
        new ShareAction(activity).withMedia(imagelocal)
                .setPlatform(share_media)
                .setCallback(shareListener).share();
    }

    /**
     * 分享网图
     *
     * @param activity
     * @param share_media
     * @param imagePath
     * @param shareListener
     */
    public static void shareImageNet(Activity activity, SHARE_MEDIA share_media, String imagePath, UMShareListener shareListener) {
        UMImage imageurl = new UMImage(activity, imagePath);
//        imageurl.setThumb(new UMImage(this, R.drawable.thumb));
        new ShareAction(activity)
                .withMedia(imageurl)
                .setPlatform(share_media)
                .setCallback(shareListener).share();
    }


}
